package com.dnb.webmash.playmaker.client.playertypes;

import com.dnb.webmash.playmaker.client.ClientFieldVerifier;
import com.dnb.webmash.playmaker.client.mediaplayer.MediaPlayer;
import com.dnb.webmash.playmaker.shared.PlayerType;
import com.google.gwt.dom.client.Document;

//universal iframe media embedder
public class IFramePlayer extends MediaPlayer{				
	public IFramePlayer() {
		myType = PlayerType.IFRAME;
		myElement = Document.get().createIFrameElement();
		setElement(myElement);		
	}		
	@Override
	protected void embed() {
		if (ClientFieldVerifier.isValidURL(this.mediaIt.getFullURL())){
			appendEmbedIFrameElement();
		}
	}	
	private void appendEmbedIFrameElement() {
		myElement.setAttribute("src", mediaIt.getFullURL());
		myElement.setAttribute("frameborder", "0");		
		myElement.setAttribute("allowScriptAccess", "always");
		getElement().appendChild(myElement);
	}
}
